home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk.zip / SCAN.H < prev    next >
C/C++ Source or Header  |  1991-04-09  |  3KB  |  108 lines

  1.  
  2. /********************************************
  3. scan.h
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the Awk programming language as defined in
  8. Aho, Kernighan and Weinberger, The AWK Programming Language,
  9. Addison-Wesley, 1988.
  10.  
  11. See the accompaning file, LIMITATIONS, for restrictions
  12. regarding modification and redistribution of this
  13. program in source or binary form.
  14. ********************************************/
  15.  
  16.  
  17. /* $Log:    scan.h,v $
  18.  * Revision 2.2  91/04/09  12:39:31  brennan
  19.  * added static to funct decls to satisfy STARDENT compiler
  20.  * 
  21.  * Revision 2.1  91/04/08  08:23:54  brennan
  22.  * VERSION 0.97
  23.  * 
  24. */
  25.  
  26.  
  27. /* scan.h  */
  28.  
  29. #ifndef  SCAN_H_INCLUDED
  30. #define  SCAN_H_INCLUDED   1
  31.  
  32. #include <stdio.h>
  33.  
  34. #ifndef   MAKESCAN
  35. #include  "symtype.h"
  36. #include  "parse.h"
  37. #endif
  38.  
  39.  
  40. extern  char scan_code[256] ;
  41.  
  42. /*  the scan codes to compactify the main switch */
  43.  
  44. #define  SC_SPACE               1
  45. #define  SC_NL                  2
  46. #define  SC_SEMI_COLON          3
  47. #define  SC_FAKE_SEMI_COLON     4
  48. #define  SC_LBRACE              5
  49. #define  SC_RBRACE              6
  50. #define  SC_QMARK               7
  51. #define  SC_COLON               8
  52. #define  SC_OR                  9
  53. #define  SC_AND                10
  54. #define  SC_PLUS               11
  55. #define  SC_MINUS              12
  56. #define  SC_MUL                13
  57. #define  SC_DIV                14
  58. #define  SC_MOD                15
  59. #define  SC_POW                16
  60. #define  SC_LPAREN             17
  61. #define  SC_RPAREN             18
  62. #define  SC_LBOX               19
  63. #define  SC_RBOX               20
  64. #define  SC_IDCHAR             21
  65. #define  SC_DIGIT              22
  66. #define  SC_DQUOTE             23
  67. #define  SC_ESCAPE             24
  68. #define  SC_COMMENT            25
  69. #define  SC_EQUAL              26
  70. #define  SC_NOT                27
  71. #define  SC_LT                 28
  72. #define  SC_GT                 29
  73. #define  SC_COMMA              30
  74. #define  SC_DOT                31
  75. #define  SC_MATCH              32
  76. #define  SC_DOLLAR             33
  77. #define  SC_UNEXPECTED         34
  78.  
  79. #ifndef  MAKESCAN
  80.  
  81. /* global functions in scan.c */
  82.  
  83. void  PROTO(scan_init, (int, char *) ) ;
  84. void  PROTO(scan_cleanup, (void) ) ;
  85. void  PROTO(eat_nl, (void) ) ;
  86. int   PROTO(yylex, (void) ) ;
  87.  
  88.  
  89. extern  YYSTYPE  yylval ;
  90.  
  91. #define  ct_ret(x)  return current_token = (x)
  92.  
  93. #define  next() (*buffp ? *buffp++ : slow_next())
  94. #define  un_next()  buffp--
  95.  
  96. #define  ifnext(c,x,y) (next()==c?x:(un_next(),y))
  97.  
  98. #define  test1_ret(c,x,d)  if ( next() == (c) ) ct_ret(x) ;\
  99.                            else { un_next() ; ct_ret(d) ; }
  100.  
  101. #define  test2_ret(c1,x1,c2,x2,d)   switch( next() )\
  102.                                    { case c1: ct_ret(x1) ;\
  103.                                      case c2: ct_ret(x2) ;\
  104.                                      default: un_next() ;\
  105.                                               ct_ret(d) ; }
  106. #endif  /* ! MAKESCAN  */
  107. #endif
  108.